﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class DanhSachMucRaoVatChinh : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e) 
    {
        LinQ_RaoVatDataContext danhsach = new LinQ_RaoVatDataContext();

        var query = from Danh_Muc_Chinh in danhsach.DANH_MUC_CHINHs
                    where Danh_Muc_Chinh.Deleted == false
                    orderby Danh_Muc_Chinh.TenDanhMucChinh ascending
                    select Danh_Muc_Chinh;
        if (query.Count() == 0)
        {
            Response.Write("<script> alert('Chưa có dữ liệu');</script>");
        }
        else
        {
            GridView1.DataSource = query;
            GridView1.DataBind();
        }
    }
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            DANH_MUC_CHINH objTin = (DANH_MUC_CHINH)e.Row.DataItem;
            HyperLink hplTenDanhMucChinh = (HyperLink)e.Row.FindControl("hplTenDanhMucChinh");
            hplTenDanhMucChinh.Text = objTin.TenDanhMucChinh;
            hplTenDanhMucChinh.NavigateUrl = "~/RaoVat/DanhSachMucRaoVatCon.aspx?id=" + objTin.MaDanhMucChinh;            
        }
    }
}
